<template>
  <div class="app-wrapper">
    <div :class="{ 'fixed-header': $store.state.settings.fixed_header }">
      <navbar />
    </div>
    <div class="flex">
      <sidebar :aMenu="adminMenu" style="z-index: 9" v-if="menuState" />
      <app-main v-if="adminMenu.length > 0" />
    </div>
  </div>
</template>
<script>
import Navbar from "./component/navbar";
import Sidebar from "@/layout/components/sidebar/adminNew";
import AppMain from "@/layout/components/appmain/adminNew";

export default {
  components: {
    Navbar,
    Sidebar,
    AppMain
  },
  data() {
    return {
      menuState: !this.$route.query.app_auth_code
    };
  },
  watch: {
    $route(to) {
      if (to.meta?.route) {
        sessionStorage.setItem("paySalaryPage", to.meta.route);
      }
    }
  },
  computed: {
    adminMenu() {
      const arr = [];
      if (this.$hasPermission("transferAccount:faxinshenqing:query")) {
        arr.push({
          icon: "yonggongzonglan",
          name: "发薪申请",
          router: "/paySalary/applyFor"
        });
      }
      if (this.$hasPermission("transferAccount:faxinshenhe:query")) {
        arr.push({
          icon: "yonggongzonglan",
          name: "发薪审核",
          router: "/paySalary/examine"
        });
      }
      if (this.$hasPermission("transferAccount:xinzifafang:query")) {
        arr.push({
          icon: "yonggongzonglan",
          name: "薪资发放",
          router: "/paySalary/pay"
        });
      }
      if (this.$hasPermission("transferAccount:faxinrenyuanku:query")) {
        arr.push({
          icon: "yonggongzonglan",
          name: "薪资人员库",
          router: "/paySalary/people"
        });
      }
      if (this.$hasPermission("transferAccount:faxinzhanghaoshezhi:query")) {
        arr.push({
          icon: "yonggongzonglan",
          name: "发薪账号设置",
          router: "/paySalary/merchant"
        });
      }
      return arr;
    }
  },
  destroyed() {
    sessionStorage.setItem("paySalaryPage", "");
  }
};
</script>
